package com.ruoyi.project.lely.controller;


import com.ruoyi.common.R;
import com.ruoyi.project.lely.bean.entity.LyCategory;
import com.ruoyi.project.lely.service.LyCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author luoyong
 * @Desc: 类目菜单
 * @since 2022-01-13
 */
@Api(tags = "Mini-菜品分类")
@RestController
@RequestMapping("/mini/category")
public class CategoryController {

    @Autowired
    private LyCategoryService categoryService;

    @ApiOperation("查询分类数据-全部")
    @GetMapping(value = {"/get"})
    public R get() {
        List<LyCategory> list = categoryService.list();
        return R.ok(list);
    }

    @ApiOperation("查询当前分类数据")
    @GetMapping("/current")
    public R current(@ApiParam(value = "父分类id", required = true) @RequestParam Long id) {
        return categoryService.getCurrent(id);
    }
}

